﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Master/default.Master" AutoEventWireup="true"
    CodeBehind="Zonal-Plan.aspx.cs" Inherits="NRCP.Zonal_Plan" %>

<%@ Import Namespace="NRCP.Helpers" %>
<%@ Register Assembly="NRCP" Namespace="UI.Library.Web" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
 <script type="text/javascript">
     $(document).ready(function () {
         $('table[id^="grd-"]').each(function () {
             var IsPlanComplete = true;
             var lnkId = $(this).attr('id').split('-')[1];
             $("#" + $(this).attr('id') + " tbody tr").each(function () {
                 var status = $(this).find("td:nth-child(3)").text().trim();
                 if (status == "Pending") {
                     IsPlanComplete = false;
                 }
             });

             if (IsPlanComplete) {
                 $("#lnk-" + lnkId).hide();
             }
             else {

                 $("#lbl-" + lnkId).hide();
             }

         });
     });
   </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <br class="clear" />
    <div class="grid_24 main-content alpha">
        <ul class="breadcrumbs css3-support">
            <li class="firstb css3-support"><a class="active">
                <h1>
                    1</h1>
                National Plan</a> </li>
            <li class="css3-support"><a class="active">
                <h1>
                    2</h1>
                Yearly Plan</a> </li>
            <li class="css3-support"><a class="active">
                <h1>
                    3</h1>
                Monthly Plan</a> </li>
            <li style="background: none"><a>
                <h1>
                    4</h1>
                Finish</a> </li>
        </ul>
    </div>
    <br class="clear" />
    <div class="grid_20 form-contents alpha">
        <cc1:ResponseMessage ID="respMessage" runat="server"></cc1:ResponseMessage>
    </div>
    <br class="clear" />
    <div class="clear">
    </div>
    <asp:Repeater ID="repYearlyPlan" runat="server" OnItemDataBound="repYearlyPlan_ItemDataBound">
        <ItemTemplate>
            <div class="grid_20">
                <div class="grid_4 report-title-sub clarfix alpha">
                    <%# Eval("Division.Name")%>
                </div>
                <br class="clear" />
                <table id="dataTable" class="mGrid">
                    <tr>
                        <th>
                            Fish Type
                        </th>
                        <th>
                        </th>
                        <th>
                        </th>
                    </tr>
                    <asp:Repeater ID="repBreakdownByFish" runat="server" OnItemDataBound="repBreakdownByFish_ItemDataBound">
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <%# Eval("Fish.Name")%>
                                    <asp:HiddenField ID="hidDivisionName" runat="server" Value=' <%# DataBinder.Eval(Container.Parent.Parent, "DataItem.Id") %>' />
                                </td>
                                <td>
                                    <asp:Panel ID="pnlPlanDetails" runat="server" Visible="true">                                    
                                    <table class="mGrid" id='<%# "grd-"+Eval("Fish.Name")+ DataBinder.Eval(Container.Parent.Parent, "DataItem.Id")%>'>
                                    <thead>
                                        <tr>
                                            <th>
                                                Chemical Group
                                            </th>
                                            <th>
                                                Count
                                            </th>
                                            <th>
                                                Status
                                            </th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <asp:Repeater ID="repBreakdownByGroups" runat="server">
                                            <ItemTemplate>
                                                <tr>
                                                    <td>
                                                        <%# Eval("NationalPlanChemicalGroup.ChemicalGroup.Name")%>
                                                    </td>
                                                    <td>
                                                        <%# Eval("Count")%>
                                                    </td>
                                                    <td>
                                                        <%# Eval("Status")%>
                                                    </td>
                                                </tr>
                                            </ItemTemplate>
                                        </asp:Repeater>
                                        </tbody>
                                    </table>
                                    </asp:Panel>
                                     <asp:Panel ID="pnlEmpty" runat="server" Visible="false">     
                                     <span class="green-mark">N/A</span> 
                                     </asp:Panel>
                                </td>
                                <td>
                                <asp:Panel ID="pnlOptions" runat="server" Visible="true">   
                                    <a id='<%# "lnk-"+Eval("Fish.Name")+ DataBinder.Eval(Container.Parent.Parent, "DataItem.Id")%>' href='<%= SiteSettings.BaseUrl %>monthly-zonal-plan.aspx?params=<%= SiteUtility.QueryParam %>&divisionId=<%# DataBinder.Eval(Container.Parent.Parent, "DataItem.Id") %>&fishId=<%# Eval("Fish.Id")%>'
                                        class="button small gray">Create Monthly Plan</a>
                                     <label id='<%# "lbl-"+Eval("Fish.Name")+ DataBinder.Eval(Container.Parent.Parent, "DataItem.Id")%>' class="green-mark">Monthly Plan Created</label>
                                     </asp:Panel>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </table>
                <br class="clear" />
            </div>
        </ItemTemplate>
    </asp:Repeater>
    <br />
    <br class="clear" />
    <asp:Button ID="btnSaveAll" runat="server" Text="Save & Continue" CausesValidation="false" 
        CssClass="button medium green" onclick="btnSaveAll_Click" Visible="false" />
</asp:Content>
